import numbers
class Group:
    #支持切片操作
    def __init__(self,group_name,company_name,staffs):
        self.group_name=group_name
        self.company_name=company_name
        self.staffs=staffs

    def __reversed__(self):
        self.staffs.reverse()

    def __getitem__(self, item):
        cls=type(self)
        print(cls)
        if isinstance(item,slice):
            return cls(group_name=self.group_name,company_name=self.company_name,staffs=self.staffs[item])
        elif isinstance(item,numbers.Integral):
            return cls(group_name=self.group_name,company_name=self.company_name,staffs=[self.staffs[item]])

    def __len__(self):
        return len(self.staffs)

    def __iter__(self):
        return iter(self.staffs)

    def __contains__(self, item):
        if item in self.staffs:
            return True
        else:
            return False
staffs=['t1','t2','t3','t4']
group=Group(company_name='imooc',group_name='user',staffs=staffs)
print(group[:2])
print(group.staffs)
print(group[0])
if 't1'  in group:#会调用__contains__
    print('yes')
